package com.cskaoyan.javase.oop2.initialization6.exercise4;

/**
 * @description: 小练习
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

public class Demo {
    public static void main(String[] args) {
        PrimaryStudent primaryStudent = new PrimaryStudent(666,888,"hello");
        System.out.println(primaryStudent.psVar);
        System.out.println(primaryStudent.sVar);
        System.out.println(primaryStudent.sVarString);
    }
}
class Person {
    public Person() {
        //这里隐含了super()但是Object对本程序没影响
        System.out.println("Person类的无参构造"); //1
    }
}
class Student extends Person {
    int sVar; //默认初始化值是0
    String sVarString; //null 如果有显式赋值，这里也会显式赋值
    public Student() {
        System.out.println("Student类无参构造");
    }
    public Student(int sVar) {
        //这里隐含了super()
        System.out.println("Student int构造方法"); //2
        this.sVar = sVar; //888 0--->888 再次赋值
    }
    public Student(int sVar, String sVarString) {
        this(sVar);
        System.out.println("Student int String构造方法"); //3
        this.sVarString = sVarString; //hello 立刻赋值null--->hello
    }
}
class PrimaryStudent extends Student {
    int psVar = 10; //这里是有0--->10 立刻初始化当前类的成员变量 0-->10
    public PrimaryStudent(int psVar, int sVar, String sVarString) {
        super(sVar, sVarString);
        System.out.println("PrimaryStudent类的 三参构造");//4
        this.psVar = psVar; //10--->666
        //走到构造器以后，这个变量已经初始化完毕了，构造器只是赋值
    }
}